/*
Problem:    Climbing Stairs
Difficulty: Medium
Source:     http://www.leetcode.com/onlinejudge
Notes:
You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

*/

class Solution {
public:
    int memo[100];
    int fib(int n) {
        if (n == 0 || n == 1) {
            return 1;
        }
        memo[n - 1] = (memo[n - 1] == -1 ? fib(n - 1) : memo[n - 1]);
        memo[n - 2] = (memo[n - 2] == -1 ? fib(n - 2) : memo[n - 2]);
        return memo[n - 1] + memo[n - 2];
    }

    int climbStairs(int n) {
        memset(memo, -1, sizeof(memo));

        return fib(n);
    }
};